//package com.yang.lock;
//
//import com.yang.lock.config.LockConfig;
//import com.yang.lock.core.BusinessKeyProvider;
//import com.yang.lock.core.LockInfoProvider;
//import com.yang.lock.lock.LockFactory;
//import io.netty.channel.nio.NioEventLoopGroup;
//import org.redisson.Redisson;
//import org.redisson.api.RedissonClient;
//import org.redisson.config.Config;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.AutoConfigureAfter;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
//import com.yang.lock.core.LockAspectHandler;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Import;
//
///**
// * <p>
// * 自动装配
// * </p>
// * @author yang
// * @date 2023/7/13
// */
//@Configuration
//@ConditionalOnProperty(prefix = LockConfig.PREFIX, name = "enable", havingValue = "true", matchIfMissing = true)
//@AutoConfigureAfter(RedisAutoConfiguration.class)
//@EnableConfigurationProperties(LockConfig.class)
//@Import({LockAspectHandler.class})
//public class LockAutoConfiguration {
//
//    @Autowired
//    private LockConfig lockConfig;
//
//    @Bean(destroyMethod = "shutdown")
//    @ConditionalOnMissingBean
//    RedissonClient redisson() {
//        Config config = new Config();
//
//        if(lockConfig.getClusterServer()!=null){
//            config.useClusterServers().setPassword(lockConfig.getPassword())
//                    .addNodeAddress(lockConfig.getClusterServer().getNodeAddresses());
//
//        }else {
//
//            config.useSingleServer().setAddress(lockConfig.getAddress())
//                    .setDatabase(lockConfig.getDatabase())
//                    .setPassword(lockConfig.getPassword());
//        }
//        config.setEventLoopGroup(new NioEventLoopGroup());
//        return Redisson.create(config);
//    }
//
//    @Bean
//    public LockInfoProvider lockInfoProvider(){
//        return new LockInfoProvider();
//    }
//
//    @Bean
//    public BusinessKeyProvider businessKeyProvider(){
//        return new BusinessKeyProvider();
//    }
//
//    @Bean
//    public LockFactory lockFactory(){
//        return new LockFactory();
//    }
//}
